<link rel="stylesheet" href="../addons/jy_exchange/css/common.css?v=2019">
<div class='fui-page fui-page-current'>
    <div class="fui-content">
        <div class="block-exchange">
            <div class="title">
                <p class="text">兑换中心</p>
                <p class="text2" style="display: none;">兑换码: {{pagedata.item.code}}</p>
                <p class="num">此兑换码已查询<span id="num">1</span>次</p>
            </div>
            <div class="input">
                <input placeholder="请输入兑换码" id="exchangeno" ng-model="pagedata.item.code"/>
            </div>
			<div class="btn btn-danger block" ng-click="pagedata.pay();" id="exchange">马上兑换</div>
			</div>

        <div class="block-info">
            <div class="head">
                <div class="title">兑换中心</div>
            </div>
            <div class="info">
                <p><b>兑换规则</b></p>
                <p>{{pagedata.rule}}</p>
            </div>
        </div>
        <div class="alert-success-outer" style="display: none;">
            <div class="alert-success">
                <div class="text" id="status1">恭喜！兑换成功！</div>
                <div class="btn btn-warning">确定</div>
            </div>
        </div>
        <div class="alert-error-outer" style="display: none;">
            <div class="alert-error">
                <div class="text" id="status0">很遗憾！兑换码已失效！</div>
                <div class="btn btn-warning">知道了</div>
            </div>
        </div>
		<div class="fui-cell-group fui-cell-click" style="background:none;padding:0 2rem">
			<a class="fui-cell external changepwd" href="javascript:;" ng-click="access_json('jy_weishop/member.index/')">
				<div class="fui-cell-text" style="text-align: center;">返回会员中心</div>
			</a>
		</div>
    </div>
   
</div>
<script>
scope.pagedata.pay=function(){
    scope.post_json('jy_exchange/index/post/',scope.pagedata.item,function(res){
		if(res.id && res.payid){
			scope.pagedata.order_id=res.id;
			var success_url ='jy_exchange/index/'
			scope.tool.pay(res.payid,function(res){
					if(res.type=='success'){
						scope.message('支付成功！','success',success_url);
					}else{
						scope.message('支付失败！','success',success_url);
					}
			},'','',success_url,success_url);
		}else{
			scope.message(res,'success',success_url);
		}
	});
}
</script>